package com.cdtye.shuoh.service.device;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.cdtye.common.webcore.web.AjaxJson;
import com.cdtye.shuoh.domain.device.entity.Device;
import com.cdtye.shuoh.domain.device.model.TlvDeviceParams;
import com.cdtye.shuoh.domain.device.vo.DeviceVo;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public interface DeviceService extends IService<Device> {

    List<Device> selectList(DeviceVo vo);

    /**
     * 根据id获取设备信息
     * @param id
     * @return
     */
    Device getById(String id);

    /**
     * 根据设备标识获取设备信息
     * @param deviceIdentification
     * @return
     */
    Device findOneByDeviceIdentification(String deviceIdentification);

    /**
     * 根据设备标识更新设备状态
     * @param deviceIdentification
     * @param connectStatus
     * @return
     */
    Boolean updateDeviceConnectStatusByDeviceIdentification(String deviceIdentification, String connectStatus);

    /**
     * 根据clientId更新设备连接状态
     * @param clientId
     * @param connectStatus
     * @return
     */
    Boolean updateDeviceConnectStatusByClientId(String clientId,String connectStatus);

    /**
     * 新增设备
     * @param device
     * @return
     * @throws Exception
     */
    AjaxJson insertDevice(Device device) throws Exception;

    /**
     * 根据connetor获取设备信息
     * @param connector
     * @return
     */
    Device findOneByConnector(String connector);

    /**
     * 根据设备类型查询
     * @param deviceType
     * @return
     */
    List<Device> findByDeviceType(String deviceType);

    /**
     * 根据connector更新设备状态
     * @param connector
     * @param connectStatus
     * @return
     */
    Boolean updateDeviceConnectStatusByConnector(String connector, String connectStatus);

    /**
     * 分页查询
     * @param deviceVo
     * @return
     */
    IPage<Device> pageList(DeviceVo deviceVo);

    /**
     * 更新设备信息
     * @param vo
     * @return
     */
    int updateDevice(DeviceVo vo);

    /**
     * 根据id删除设备
     * @param id
     * @return
     */
    int deleteById(String id);

    /**
     *
     * @param clientId
     * @return
     */
    Device findOneByClientId(String clientId);

    void updateDeviceByDeviceIdentification(Device device);

    Map<String,Object> connectStatusStatistic();

    List<Map<String,Object>> deviceTypeStatistic();

    List<Map<String,Object>> deviceStatusStatistic();
}
